-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Resource Access Control] [Part1] Introduces SPI for resource access control #5185
base: feature/resource-permissions
Are you sure you want to change the base?
[Resource Access Control] [Part1] Introduces SPI for resource access control #5185
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/resource-permissions #5185 +/- ##
================================================================
- Coverage 71.71% 71.69% -0.03%
================================================================
Files 337 337
Lines 22789 22790 +1
Branches 3606 3606
================================================================
- Hits 16344 16340 -4
- Misses 4649 4653 +4
- Partials 1796 1797 +1
🚀 New features to boost your workflow:
|
d076506
to
ccc5022
Compare
spi/src/main/java/org/opensearch/security/spi/resources/Resource.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/Resource.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/ResourceSharingExtension.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
9833c7e
to
3379974
Compare
spi/src/main/java/org/opensearch/security/spi/resources/ResourceAccessScope.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Darshit Chanpura <[email protected]>
cb45e7e
to
63c4a27
Compare
Signed-off-by: Darshit Chanpura <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this interesting PR @DarshitChanpura !
Like in #5194, I have added a couple of comments and questions. As I went through the code linearly, I also commented both on conceptual things and code level things (which I mostly marked with Nit:). I would recommend that you first have a look on conceptual things ... we can talk about the Nit stuff later.
...src/main/java/org/opensearch/security/spi/resources/exceptions/ResourceSharingException.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/sharing/Creator.java
Show resolved
Hide resolved
public enum Recipient { | ||
USERS("users"), | ||
ROLES("roles"), | ||
BACKEND_ROLES("backend_roles"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that some plugins use backend roles for sharing. However, this might lead to sub-optimal situations, as users might have different backend roles depending on the auth system they are using. If we need to support BACKEND_ROLES
, it should be marked IMHO as deprecated with the suggestion to use ROLES
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BACKEND_ROLES are added to support transition from filterByBackendRoles authz mechanism to this. This will allow migration to be easier. Maybe we deprecate this in next iteration of this feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just deprecating it won't really affect migration negatively. It would just send the message "in the future, please use other means". Or do I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be decided in v2 of this feature. For now, the idea is to centralize the resource authz mechanism.
spi/src/main/java/org/opensearch/security/spi/resources/sharing/RecipientType.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/sharing/ResourceSharing.java
Show resolved
Hide resolved
spi/src/test/java/org/opensearch/security/spi/resources/ShareWithTests.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/ResourceAccessScope.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/ResourceAccessScope.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/sharing/SharedWithScope.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/security/spi/resources/sharing/ShareWith.java
Outdated
Show resolved
Hide resolved
Proposal on path forward for scopes:To add to the comment here, Scopes can be thought of as placeholders for action groups. The question here is whether we should include Scopes in this iteration of the feature, at all. From what I see there are 3 paths forward: Path 1: No Scopes{
"share_with": {
"users": [...],
"roles": [...],
"backend_roles": [...]
}
} With this structure there is no concept of "scope". The document will be visible on 3 levels: Private, Restricted and Public. Here is what a sample resource-sharing document will look like in each case:
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": { }
}
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": {
"users": [...],
"roles": [...],
"backend_roles": [...]
}
}
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": {
"users": ["*"],
"roles": ["*"],
"backend_roles": ["*"]
}
} Pros:
Cons:
Path 2: Placeholder for Scopes{
"share_with": {
"*" : {
"users": [...],
"roles": [...],
"backend_roles": [...]
}
}
} With this structure we introduce a default scope "" which acts as a place holder for action-groups to be declared when a standalone Resource Authorization framework is in place. "" allows all actions to be matched.
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": {
"*" : { }
}
}
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": {
"*": {
"users": [...],
"roles": [...],
"backend_roles": [...]
}
}
}
{
"resource_id": "id",
"source_idx": "resource-index",
"created_by": {
"user": "x"
},
"share_with": {
"*": {
"users": ["*"],
"roles": ["*"],
"backend_roles": ["*"]
}
}
} Pros:
Cons:
Path 3: Continue with scopesThis approach allows defining individual access type over each resource. It doesn't rely completely on the APIs. It can be in future expanded to be mapped to action groups when resource authorization framework is implemented. Example, AD plugin can, at present, define a scope named Here is what an example detector sharing record may look like: {
"resource_id": "detector1",
"source_idx": ".opendistro-anomaly-detectors",
"created_by": {
"user": "darshit"
},
"share_with": {
"ad_read_only" : {
"users": [...],
"roles": [...],
"backend_roles": [...]
},
"ad_full_access" : {
"users": [...],
"roles": [...],
"backend_roles": [...]
}
}
} or if the detector is intended to be publicly accessible: {
"resource_id": "detector1",
"source_idx": ".opendistro-anomaly-detectors",
"created_by": {
"user": "darshit"
},
"share_with": {
"*" : {
"users": ["*"],
"roles": ["*"],
"backend_roles": ["*"]
}
}
}
Pros:
Cons:
@nibix @cwperks @derek-ho Please review this proposal so we can finalize the path-forward for scopes. I lean towards Path 2 as it is good place between no scopes and complete scopes, and it unblocks this PR. It would require some re-work in following Part 2 and 3 tho. |
Path 3 puts us in a good state for future, but I don't want that to be a blocker for this PR. All changes are labelled as |
Signed-off-by: Darshit Chanpura <[email protected]>
fa10c26
to
eaa92b0
Compare
Thank you for the proposals! Before I am going into the proposals, I'd like to go one step back and try to get a better picture of the situation. Sorry if the following question may sound dumb, but I am possibly missing some details at the moment. So, my question would be: What's the actual reason we are now discussing these options about the path forward with scopes?
I think an answer to this question could help me to contribute better to this discussion. |
Not conceptually, more on implementation. @DarshitChanpura has introduced a notion of "scopes" and can elaborate on them and their implementation. At the onset of this project, I had imagined re-using action groups since its an existing mechanism to group an enumerable list of actions together. Conceptually, a "scope" is a group of actions that can be performed on a resource and the owner of the resource gets to specify the level of access when sharing. For an example, we use a tool for doc reviews that has 4 different access levels when sharing a document. The access levels are "Read Only", "Read + Comment", "Edit" (allows read, comment, edit, but not share) and "Full Access" which includes the ability to share a document. These are examples of what the scopes would be for a plugin. FYI scopes (or action groups) for resource authorization breaks with the current security model where the cluster administrator is the one assigning permissions. I think alerting is a good example of a plugin that has multiple levels of access that could benefit from more fine-grained access on sharable resources. They already define 3 default roles to include in the default distribution. |
Yes, there is some confusion around implementation of scopes. Scopes do not equate to any action-groups or resolve to any set of actions, at the moment in this PR. They are added to allow resources to be shared with an additional layer of security, meaning even if a user possesses access to, say a GET detector API, they would additionally need READ scope access. This sets us in a good state when Resource Authz framework is implemented as a standalone framework (with Resource Request and ResourcePrivEvaluator). At the moment, Resource Authz works on top of existing authz framework. To avoid, any sort of confusion, I've put in a proposal for paths forward for this feature. The idea is to at least address ML-commons use case where they declare three types of access to resources: Private, Restricted and Public (as described in Paths 1 and 2 above). This allows us to achieve the final implementation of scopes (or action-groups) when we implement the standalone framework. I believe Path 2 is a good setup which is forward-looking and also resolves Ml-commons use case. |
Thank you for your replies! I think a part of my personal confusion is caused by the fact that the word "scope" can mean so many things. It could also mean the audience a resource is shared with - that was actually my first intuition. It took me a while to find that this is wrong. So, IMHO, I'd hope that a lot of the confusion could be resolved by finding another name for scopes, which is more precise and more intuitive. What do you think? |
Scope is the level at which the resource is shared.
Yes that can be done. However, the important question here is which path to proceed with, out of the three. |
Signed-off-by: Darshit Chanpura <[email protected]>
…into resource-sharing-spi-only
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
I've update this PR and subsequent parts to reflect action-groups change following Path 2 from design proposals put forward here: #5185 (comment) |
Signed-off-by: Darshit Chanpura <[email protected]>
6b218d9
to
dafd5c3
Compare
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
...rc/main/java/org/opensearch/security/spi/resources/exceptions/ResourceNotFoundException.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
44739a6
to
c9e2485
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM from a high level, I will take a look at part 2 and 3 to see if there is anything else concerning on this PR
#5016 is being broken down into smaller pieces. This is part 1.
Description
Introduces an SPI to implement Resource Access Control in OpenSearch. This will allow plugins to declare itself as Resource Plugins to leverage the access control methods to be provided by Security plugin.
Issues Resolved
Related to #4500
Testing
Check List
- [ ] New functionality includes testing- [ ] New functionality has been documented~- [ ] New Roles/Permissions have a corresponding security dashboards plugin PR
- [ ] API changes companion pull request createdBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.